import 'dart:convert';
import 'package:flutter/services.dart';

class Meow {
  String mp3;
  String title;
  String src;

  Meow({this.mp3, this.title, this.src});

  Meow.fromJson(Map<String, dynamic> json) {
    mp3 = json['mp3'];
    title = json['title'];
    src = json['src'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['mp3'] = this.mp3;
    data['title'] = this.title;
    data['src'] = this.src;
    return data;
  }

  static Future<List<Meow>> queryMeows() async {
    String JSON = await rootBundle.loadString('assets/meow.json');
    var data = json.decode(JSON);
    if (data is List) {} else {
      return [];
    }
    List<Meow> result = [];
    for (var item in data) {
      var meow = Meow.fromJson(item);
      if (meow != null) result.add(meow);
    }
    return result;
  }
}